function GenerateBookmarklet() {
 var bm = document.getElementById("analyticsbookmarklet") ;
 var url = document.getElementById("analytics-url").value ;
 var idmatch = url.match(/[?&](\w*id=\d+)/) ;
 if(!idmatch) {
 	idmatch = url.match(/[?&](\w*scid=\d+)/) ;
 }
 if (idmatch) {
//	bm.href = 'javascript:with({year:1900+(new%20Date()).getYear(),month:1+(new%20Date()).getMonth(),day:(new%20Date()).getDate()}){var%20d1=year%20+%20""%20+%20(month-1%20<%2010%20?%20"0"%20:%20"")%20+%20month-1%20+%20(day%20<%2010%20?%20"0"%20:%20"")%20+%20day;var%20d2=year%20+%20""%20+%20(month%20<%2010%20?%20"0"%20:%20"")%20+%20month%20+%20(day%20<%2010%20?%20"0"%20:%20"")%20+%20day;location.href="https://www.google.com/analytics/reporting/?reset=1&'+idmatch[1]+'&pdr="+d1+"-"+d2;}';
	bm.href = 'javascript:with({year:1900+(new%20Date()).getYear(),month:1+(new%20Date()).getMonth(),day:(new%20Date()).getDate()}){var%20lmday=day;var%20lm=month-1;if(day==31)%20{%20lmday=1;%20lm=month;%20}var%20d1=year%20+%20""%20+%20(lm%20<%2010%20?%20"0"%20:%20"")%20+%20lm%20+%20(lmday%20<%2010%20?%20"0"%20:%20"")%20+%20lmday;var%20d2=year%20+%20""%20+%20(month%20<%2010%20?%20"0"%20:%20"")%20+%20month%20+%20(day%20<%2010%20?%20"0"%20:%20"")%20+%20day;location.href="https://www.google.com/analytics/reporting/?reset=1&'+idmatch[1]+'&pdr="+d1+"-"+d2;}'

  bm.innerHTML = "Real-time Analytics" ;
	var f = document.getElementById("analyticsresult") ;
	var g = document.getElementById("analyticsErrorMsg") ;
	if(g)
		f.removeChild(g);
	bm.style.display = "inline";
 } else {
	var e = document.createElement('p');
	var f = document.getElementById("analyticsresult") ;
	var g = document.getElementById("analyticsErrorMsg") ;
	if(!g) {
		e.id = "analyticsErrorMsg"
		e.innerHTML = "Couldn't find your site's id in the URL" ;
		bm.style.display = "none";
		f.appendChild(e);
	}
 }
}
